package server;

import server.servlet.HttpServlet;

import java.io.IOException;

/**
 * @description:
 * @author: Archie Wan
 * @time: 2020/12/27 14:41
 */
public class MyServlet extends HttpServlet {
    @Override
    public void doGet(Request request, Response response) {
    
        try {
            Thread.sleep(100000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        
        String content = "<h1>MyServlet get</h1>";
        try {
            response.output((HttpProtocolUtil.getHttpHeader200(content.getBytes().length) + content));
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    
    @Override
    public void doPost(Request request, Response response) {
        String content = "<h1>MyServlet post</h1>";
        try {
            response.output((HttpProtocolUtil.getHttpHeader200(content.getBytes().length) + content));
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    
    @Override
    public void init() throws Exception { }
    
    @Override
    public void destroy() throws Exception { }
}
